//package org.linlinjava.litemall.wx.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.exception.ExceptionUtils;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.linlinjava.litemall.core.util.JacksonUtil;
//import org.springframework.stereotype.Component;
//import org.springframework.ui.Model;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//
///**
// * Controller过滤器拦截请求参数
// */
//@Slf4j
//@Aspect
//@Component
//public class ControllerInterceptor{
//    @Pointcut("execution(* org.linlinjava.litemall.wx.web.*.*(..))")
//    public void controllerMethodPointcut(){
//    }
//
//    @Around("controllerMethodPointcut()")
//    public Object Interceptor(ProceedingJoinPoint point) throws Throwable{
//        String methodName = point.getSignature().getDeclaringTypeName() + "." + point.getSignature().getName();
//        Object[] argsAll = point.getArgs();
//        Object[] args = new Object[argsAll.length];
//        for(int i = 0; i < argsAll.length; i++){
//            if(argsAll[i] instanceof ServletRequest
//                    || argsAll[i] instanceof ServletResponse
//                    || argsAll[i] instanceof Model
//                    || argsAll[i] instanceof MultipartFile){
//                //ServletRequest不能序列化，从入参里排除，否则报异常：java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
//                //ServletResponse不能序列化 从入参里排除，否则报异常：java.lang.IllegalStateException: getOutputStream() has already been called for this response
//                continue;
//            }
//            args[i] = argsAll[i];
//        }
//        log.info("litemall-mobile-api start ---> method:{}, args:{}", methodName, JacksonUtil.toJson(args));
//        Object returnValue = point.proceed();
//        try{
//            if(null != returnValue){
//                log.info("litemall-mobile-api success ---> method:{}, result:{}", methodName, JacksonUtil.toJson(returnValue));
//            }
//            return returnValue;
//        }
//        catch(Throwable throwable){
//            log.error("litemall-mobile-api ---> unknownException methodName:{}, args:{} ,throwable:{}", methodName,
//                    JacksonUtil.toJson(args), ExceptionUtils.getStackTrace(throwable));
//            return returnValue;
//        }
//    }
//}
